message dialog: use title style only if there is secondary text
authorMichael Catanzaro <mcatanzaro@gnome.org>
Tue, 29 Dec 2020 17:12:59 +0000 (11:12 -0600)
committerMichael Catanzaro <mcatanzaro@gnome.org>
Tue, 29 Dec 2020 17:15:14 +0000 (11:15 -0600)
If there is no secondary text, then the primary text is just a message,
not a title, and should not use title style.

This partially reverts 1e3ec7c1f993ec8cab4c6608b968e78f9028d662. The
message dialog nown looks like it used to in GTK 3. However, it's still
styled only using a style class rather than using pango markup, as in
GTK 3.

Fixes #3509

gtk/gtkmessagedialog.c
gtk/ui/gtkmessagedialog.ui

index c28f275b3a83975bead348c71d32ad1b68e69bc6..171554d8cc86855371fd8cd03a58b1904c9c1aaf 100644 (file)
@@ -383,11 +383,13 @@ gtk_message_dialog_set_property (GObject      *object,
        if (txt)
          {
            priv->has_secondary_text = TRUE;
+            gtk_widget_add_css_class (priv->label, "title");
            gtk_widget_show (priv->secondary_label);
          }
        else
          {
            priv->has_secondary_text = FALSE;
+            gtk_widget_remove_css_class (priv->label, "title");
            gtk_widget_hide (priv->secondary_label);
          }
       }
@@ -621,6 +623,7 @@ gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
   if (message_format)
     {
       priv->has_secondary_text = TRUE;
+      gtk_widget_add_css_class (priv->label, "title");
 
       va_start (args, message_format);
       msg = g_strdup_vprintf (message_format, args);
@@ -634,6 +637,7 @@ gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
   else
     {
       priv->has_secondary_text = FALSE;
+      gtk_widget_remove_css_class (priv->label, "title");
       gtk_widget_hide (priv->secondary_label);
     }
 }
@@ -677,6 +681,7 @@ gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
   if (message_format)
     {
       priv->has_secondary_text = TRUE;
+      gtk_widget_add_css_class (priv->label, "title");
 
       va_start (args, message_format);
       msg = g_strdup_vprintf (message_format, args);
@@ -690,6 +695,7 @@ gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
   else
     {
       priv->has_secondary_text = FALSE;
+      gtk_widget_remove_css_class (priv->label, "title");
       gtk_widget_hide (priv->secondary_label);
     }
 }
index c7e29be04d98c7040b4c7f960ad0d36705082194..42c6528b4aee144d3cd7f8d959f2497ac1c663b4 100644 (file)
@@ -28,9 +28,6 @@
                     <property name="valign">start</property>
                     <property name="wrap">1</property>
                     <property name="max-width-chars">60</property>
-                    <style>
-                      <class name="title"/>
-                    </style>
                   </object>
                 </child>
                 <child>